<?php
namespace jy_weishop\page;
defined('BY_JYA') or exit('error');
/*
	页面返回
*/
class goods_detail extends \plugin{
	public function getmain($return=array()){
		global $_RQ;
		global $_AR;
		$activetourl=$this->model('activity')->activetourl($_RQ['id']);
		if($activetourl!=$_AR['access_json'] && !$return['noactivetourl'] && $activetourl && $_SESSION['os']!='windows'){
			exi('','',$activetourl);
		}
		$return=$this->model('goods_item')->get_goodsitem($return);
		$return['goods']['api_data']=json_decode($return['goods']['api_data'],true);
		if($_RQ['fromuser']){
			$this->model('fenxiao')->up_fenfee($return['shopset'],$return['goods']);
		}
		if(intval($return['setting']['index_tpl'])==1 && $_SESSION['os'] != 'windows'){
			$return['htmls']=$this->template_url('goods/detail_a'.$return['setting']['index_tpl']);
		}
		if(intval($return['setting']['detail_tpl'])==1 && $_SESSION['os'] != 'windows'){
			$return['shopset']['logo']=tomedia($return['shopset']['logo']);
			$return['post']['dayid']=0;
			$return['zxout_time']=$this->model('store')->zxout_time();
			$return['buyxieyi']=$this->plugin_setting('xieyi');
			$return['goods']['imagetop']=$return['goods']['images'][0]==$return['goods']['image']?$return['goods']['images'][1]:$return['goods']['images'][0];
			$return['htmls']=$this->template_url('goods/detail_0'.$return['setting']['detail_tpl']);
		}
		if(strpos($return['goods']['no_de_sales'],'no_member_discount')===false && $return['setting']['no_vipshow']!=1){
			$return['nextlevel']=$this->model('member')->get_nextlevel(0,true);
		}
		if($return['nextlevel']['id']){
			$vipprice=$this->model('goods')->get_diyprice($return['goods'],$return['nextlevel']);
			if($vipprice>=$return['goods']['price']){
				$return['nextlevel']=array();
			}else{
				$return['goods']['vipprice']=$vipprice;
			}
		}
		$return['nextlevel']['cardbg']=tomedia($return['nextlevel']['cardbg']);
		$return['sale_tan']=model('jy_weishop/activity/sales')->gettan(2);
		return $return;
	}
}